import type { UploadUserFile } from "element-plus";

export interface GetSpuListApiParams {
  page: number;
  limit: number;
  category3Id: number;
}

// 图片
export interface SpuImageItem {
  imgName: string;
  imgUrl: string;
}

export type SpuImageList = SpuImageItem[];

// 销售属性值
export interface SpuSaleAttrValueItem {
  baseSaleAttrId: number;
  saleAttrValueName: string;
  id?: number;
}

export type SpuSaleAttrValueList = SpuSaleAttrValueItem[];

// 销售属性
export interface SpuSaleAttrItem {
  baseSaleAttrId: number; // 基础销售属性id
  saleAttrName: string;
  spuSaleAttrValueList: SpuSaleAttrValueList;
  isEdit: boolean;
  id?: number;
}

export type SpuSaleAttrList = SpuSaleAttrItem[];

export interface Spu {
  id?: number;
  category3Id?: number;
  spuName: string;
  tmId: number | undefined;
  description: string;
  spuSaleAttrList: SpuSaleAttrList;
}

export interface SpuItem extends Spu {
  spuImageList: SpuImageList; // 发送请求，接口需要的类型
}

export interface SaveSpuItem extends Spu {
  spuImageList: UploadUserFile[]; // element-plus定义的数据，收集到的数据类型
}

export type SpuList = SpuItem[];

export interface GetSpuListApiResponse {
  records: SpuList;
  total: number;
}

// 基础销售属性
/*
  [
    {
      id: 1,
      name: xxx
    }
  ]
*/
export interface BaseSaleAttrItem {
  id: number;
  name: string;
}
export type BaseSaleAttrList = BaseSaleAttrItem[];
